package com.huaxingbankas.modules.servicesimpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.huaxingbankas.modules.dao.User_Dao;
import com.huaxingbankas.modules.daoimpl.UserDaoImpl;
import com.huaxingbankas.modules.model.Users;
import com.huaxingbankas.modules.model.backup.User;
import com.huaxingbankas.modules.services.UserService;

@Service
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class UserServiceImpl implements UserService {
	@Resource
	private User_Dao userdao =new UserDaoImpl();

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public boolean save(User user) {
		// TODO Auto-generated method stub
		return userdao.save(user);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public boolean[] save(User[] users) {
		// TODO Auto-generated method stub
		return userdao.save(users);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public boolean remove(User user) {
		// TODO Auto-generated method stub
		return userdao.remove(user);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void remove(User[] users) {
		// TODO Auto-generated method stub
	   userdao.refresh(users);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public boolean removeById(Integer id) {
		// TODO Auto-generated method stub
		return userdao.removeById(id);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void removeByIds(Integer[] ids) {
		// TODO Auto-generated method stub
		userdao.removeByIds(ids);
	}

	@Override
	public List<User> findAll() {
		// TODO Auto-generated method stub
		return userdao.findAll();
	}

	@Override
	public User findById(Integer id) {
		// TODO Auto-generated method stub
		return userdao.find(id);
	}

	@Override
	public User[] findByIds(Integer[] ids) {
		// TODO Auto-generated method stub
		return userdao.find(ids);
	}

	@Override
	public void flush() {
		// TODO Auto-generated method stub
		userdao.flush();
	}

	@Override
	public boolean equal(User user) {
		// TODO Auto-generated method stub
		return userdao.findByObject(user);
	}

	@Override
	public User findByUsername(User user) {
		// TODO Auto-generated method stub
		return userdao.findByUsername(user);
	}

}
